package com.htudata.transctFlow.dao;

import com.alibaba.fastjson.JSONArray;
import com.alibaba.fastjson.JSONObject;
import java.util.List;

import com.htudata.transctFlow.mapper.TransctFlowMapper;
import com.htudata.transctLive.pojo.entity.TransctFlow;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Repository;

@Repository
public class TransctFlowDao {
  @Autowired
  private TransctFlowMapper flowMapper;
  
  public List<TransctFlow> selectFlows(List<Integer> statusList, String flowName) {
    JSONObject params = new JSONObject();
    params.put("statusList", statusList);
    params.put("flowName", flowName);
    return this.flowMapper.selectFlows(params);
  }
  
  public JSONArray getInternal3DFlowsInfo(String flowStatuses) {
    JSONObject params = new JSONObject();
    params.put("flowStatuses", flowStatuses.split(","));
    return this.flowMapper.getInternal3DFlowsInfo(params);
  }
  
  public JSONArray selectFlowIdByUser(long userId) {
    JSONObject params = new JSONObject();
    params.put("userId", Long.valueOf(userId));
    return this.flowMapper.selectFlowIdByUser(params);
  }
  
  public JSONArray selectNodeIdByUser(long userId) {
    JSONObject params = new JSONObject();
    params.put("userId", Long.valueOf(userId));
    return this.flowMapper.selectNodeIdByUser(params);
  }
  
  public int updateFlowEditStatus(String flowId, int editStatus) {
    return this.flowMapper.updateEditStatus(flowId, editStatus);
  }
  
  public JSONObject getTransctFlowHealthStatis(String transctFlowId) {
    return this.flowMapper.getTransctFlowHealthStatis(transctFlowId);
  }
  
  public JSONArray getTransctFlowLeaderBoard(String transctFlowId, int year, String field, String sort, int page, int perPage) {
    if (page == 0 && perPage == 0)
      perPage = -1; 
    return this.flowMapper.getTransctFlowLeaderBoard(transctFlowId, year, field, sort, page, perPage);
  }
}
